package com.wind.医药接口查询;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

public class EEE {

    public static void main(String[] args) {
        //API产品路径
        String host = "http://brandname.market.alicloudapi.com";
//        String path = "/kgraph/domestic_medicine_brand_name/search_medicine_standard_code/v1";
//        String path = "/kgraph/domestic_medicine_brand_name/search_brand_name/v1";
        String path = "/kgraph/domestic_medicine_brand_name/search_product_name/v1";
        String method = "GET";
        //阿里云APPCODE
        String appcode = "681f69fb972044f093f8d28ed6c25953";
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();

        //参数配置
        //搜索字符串，如：86900198000328
        querys.put("STRING", "香丹清牌珂妍胶囊");
        //搜索结果页码序列，如：1
        querys.put("PAGE_NUM", "1");


        try {
            /**
             * 重要提示如下:
             * HttpUtils请从
             * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
             * 下载
             *
             * 相应的依赖请参照
             * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
             */
            HttpResponse response = Http.doGet(host, path, method, headers, querys);
            System.out.println(response.toString());
            //获取response的body
            System.out.println(EntityUtils.toString(response.getEntity()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
